<?php

namespace app\admin\model;

use app\common\constants\MenuConstant;
use app\common\model\TimeModel;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;

class InsuranceQe extends TimeModel
{
    protected function getOptions(): array
    {
        return [
            'deleteTime' => 'delete_time',
        ];
    }

    protected $type = [
        'red_point_keys' => 'json',
        'qe_rule_ids' => 'json',
        'rating' => 'json',
    ];

    public function setVaildStartAtAttr($value){
        return empty($value) ? $value : strtotime($value);
    }

    public function getVaildStartAtAttr($value){
        return empty($value) ? $value : date('Y-m-d', $value);
    }

    public function setVaildEndAtAttr($value){
        return empty($value) ? $value : strtotime($value);
    }

    public function getVaildEndAtAttr($value){
        return empty($value) ? $value : date('Y-m-d', $value);
    }

    public function getRatingToArray(){
        
    }

    /**
     * @throws ModelNotFoundException
     * @throws DbException
     * @throws DataNotFoundException
     */
    public static function getList(): array
    {
        $field = '*';
        $list = self::field($field)->where([
            ['status', '<', 2],
        ])->select()->toArray();

        return $list;
    }

}